<template>
  <div>
  <el-table :data="orders" style="width: 100%">
    <el-table-column property="pid" label="订单编号" width="120"></el-table-column>
    <el-table-column property="users.uname" label="用户名称" width="120"></el-table-column>
    <el-table-column property="sumPrice" label="总价格"></el-table-column>
    <el-table-column property="orderDate" label="订单时间"></el-table-column>

    <el-table-column label="订单状态"><el-tag type="success">等待商户收货</el-tag></el-table-column>

    <el-table-column label="货物状态">
      <template slot-scope="scope">
        <el-tag type="success" v-if="scope.row.goodsState=='g-3'">等待收货</el-tag>
      </template>
    </el-table-column>
    <el-table-column>
      <template slot="header" slot-scope="scope">
        <el-button icon="el-icon-refresh-right" circle @click="d"></el-button>
      </template>
      <template slot-scope="scope">
        <el-button
          round
          type="primary"
          plain
          @click="updaOrders(scope.row)">确认收货</el-button>

        <el-link
          type="primary"
          @click="getOrderdetail(scope.row)"
        >查看详情
        </el-link>
      </template>
    </el-table-column>

  </el-table>
  <div>
    <!--分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageno"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>

  </div>

      <div>
        <component ref="viewdetails" is="orders_view_details"></component>
      </div>

  </div>
</template>

<script>
  import orders_view_details from "./orders_view_details";
    export default {
        name: "ordersReceiving",
      data(){
        return{
          orders:[],
          goodsState:'g-3',
          pageno: 1,
          pagesize: 5,
          total: 1
        }
      },
      methods:{
          getdataordersReceiving(){
            var obj={
              pageno:this.pageno,
              pagesize:this.pagesize,
              goodsState:this.goodsState,
              loginUserId:sessionStorage.getItem("id")
            }
              this.$axios.get("QuerypartOrders.action",{params:obj}).then(res=>{
                this.orders=res.data.records;
                this.total=res.data.total;
              }).catch(error=>{
                this.$message.error(error)
              })
          },
        handleSizeChange(val) {
          //每页范围
          this.pagesize = val;
          this.getdataordersReceiving();
        },
        handleCurrentChange(val) {
          //当前页
          this.pageno = val;
          this.getdataordersReceiving();
        },
        updaOrders(row){
             this.$axios.put("editorders.action/"+row.pid).then(res=>{
               if (res.data.code>0){
                 this.$message.success(res.data.msg);
                 this.getdataordersReceiving();
              }else {
                 this.$message.error(res.data.msg)
               }
             }).catch(error=>{
               this.$message.error(error)
             })
        },
        getOrderdetail(row){
        this.$refs.viewdetails.dialogTableVisible=true;
        this.$refs.viewdetails.Orderdetails.pId=row.id
        this.$refs.viewdetails.getOrderdetailDetails()
        },
        d(){
            this.getdataordersReceiving()
        }
      },
      created() {
        this.getdataordersReceiving()
      },
      components:{
        orders_view_details
      }
    }
</script>

<style scoped>

</style>
